from utils import ave_util, k_util, date_util
import json


# m5:=ma(c,5); 收盘
# m10:=ma(c,10);
# m30:=ma(c,30);
# rc:=ref(c,1);  日线昨天收盘价格

def MA(code, size):
    return ave_util.ave_line_price_n(code, k_util.get_day_k(code), size)


def MAK(code, size, klines):
    return ave_util.local_ave_line(code, size, 1, klines)


def REF(code, size):
    klines = k_util.day_k_local(code, size + 1)
    for one_l in klines:
        if type(one_l) is not dict:
            one_l = json.loads(one_l)
        return float(one_l['sp'])
